<!-- 记录详情 -->
<template>
	<view class="recordsView">
		<view class="appliciation" v-for="(item,index) in recordsList" :key="index">
			<view class="methods">
			<text class="method">{{item.details}}</text>
			<text class="money">{{item.money}}</text>
			</view>
			<view class="date">
				{{item.createTime}}
			</view>
		</view>
	</view>
</template>

<script>
	
	export default {
		data() {
			return {
				 recordsList:[],
				 refreshing: false,
				 fetchPageNum: 1,
				 pullFlag: true,
				 contentText: '上拉显示更多',
				 pageSize: 10
			}
		},
		onLoad(e) {
			this.getsubmitDetail(e.id);
			console.log(e);
			uni.setStorageSync('id', e.id);
		},
		onShow() {
			this.fetchPageNum = 1;
			this.pullFlag = true;
			this.refreshing = false;
			console.log('请求token', uni.getStorageSync('token'));
			this.getsubmitDetail();
		},
		onReachBottom() {
			console.log('滑动到页面底部');
			this.contentText = '加载中...';
			if(this.pullFlag){
				this.fetchPageNum += 1;
				this.pullsubmitDetail();
			}else{
				this.contentText = '暂无更多数据';
			}
			
			
		},
		onPullDownRefresh() {
			// this.reload=true;
			console.log('下拉刷新');
			// this.pullData();
			uni.startPullDownRefresh({
				//API开始下拉刷新操作
				success: res => {
					console.log('shuacin', this.fetchPageNum);
					this.refreshing = true;
					this.getsubmitDetail(); //下拉刷新重新获取数据
					uni.stopPullDownRefresh(); //API停止下拉刷
					
				}
			});
		},
		methods: {
			pullsubmitDetail(id){
				uni.request({
					url:this.$serverUrl+'/app/hospital/fundRecord/listBySubmitId', //仅为示例，并非真实接口地址。
					data: {
						'pageNumber':this.fetchPageNum,
						'pageSize':this.pageSize,
						'submitId':id
					},
					method:"POST",
					header:{
						'token': uni.getStorageSync('token'),
						'content-type': "application/json",
						'content-type': "application/x-www-form-urlencoded"
					}, 
					success:( res )=> {
						
						if (res.data.code == 0) {
							// console.log("findSentimentManagerList == "+JSON.stringify(res));
							if (this.refreshing) {
								uni.showToast({
									title: '已经最新',
									icon: 'none'
								});
								this.refreshing = false;
								uni.stopPullDownRefresh();
								return;
							}
							let lists = [];
							let data = res.data.data;
							for (let i = 0; i < data.length; i++) {
								lists.push(data[i]);
							}
							if (lists.length < this.pageSize) {
								this.pullFlag = false;
								
							}
							console.log('得到lists', lists);
							
								this.recordsList =this.recordsList.concat(lists);
							
								console.log(this.recordsList);
							
						}
						try {
							uni.setStorageSync('data', JSON.stringify(res.data.data));
						} catch (e) {}
					}
				});
			},
			getsubmitDetail(id){
				uni.request({
					url:this.$serverUrl+'/app/hospital/fundRecord/listBySubmitId', //仅为示例，并非真实接口地址。
					data: {
						'pageNumber':1,
						'pageSize':this.pageSize,
						'submitId':id
					},
					method:"POST",
					header:{
						'token': uni.getStorageSync('token'),
						'content-type': "application/json",
						'content-type': "application/x-www-form-urlencoded"
					}, 
				success:( res )=> {
					if (res.data.code == 0) {
						console.log(res.data);
						if (this.refreshing) {
							uni.showToast({
								title: '已经最新',
								icon: 'none'
							});
							this.refreshing = false;
							uni.stopPullDownRefresh();
							
							return;
						}
						let lists = [];
						let data = res.data.data;
						for (let i = 0; i < data.length; i++) {
							lists.push(data[i]);
						}
						if (lists.length < this.pageSize) {
							this.contentText = '暂无更多数据';
						}
						this.lists=res.data.data;
						console.log('得到lists', lists);
						if (this.refreshing) {
							this.refreshing = false;
							uni.stopPullDownRefresh();
							this.recordsList = lists;
							
						} else {
							this.recordsList = lists;
							console.info("this.fetchPageNum == "+this.fetchPageNum)
							// this.fetchPageNum += 1;
							console.log(this.recordsList);
						}
					}
					try {
						uni.getStorageSync('data', JSON.stringify(res.data.data.token));
					} catch (e) {}
				}
				});
			}
		}
	}
</script>

<style>
	.recordsView {
		flex-direction:column;
		width: 750upx;
	}
	
	.single{
		margin-left: 40upx;
		margin-right: 40upx;
	}
	.inputLine{
		margin-left:20upx;
	}
	.inputData{
		margin-left: 10upx;
	}
	.chooses{
		margin-top: 50upx;
		/* margin-left:20upx; */
		height: 100upx;
		border-bottom-style: solid;
		border-bottom-width: 5upx;
		border-bottom-color: #ddd;
		background-color: #fff;
	}
	.appliciation{
		margin: 30upx;
		flex-direction:column;
		height:200upx;
		border-bottom-style: solid;
		border-bottom-width: 5upx;
		border-bottom-color: #ddd;
		
	}
	
	.methods{
		margin-top: 40upx;
		flex-direction:row;
		text-align: center;
	}
	
	.method{
		height: 70%;
		width:70%;
		flex-direction:row;
		align-items: center;
		text-align:left;
		/* background-color:#333333; */
	}
	.money{
		width: 30%;
		flex-direction:row;
		align-items: center;
		text-align:right;
		/* background-color: #007AFF; */
	}
	.date{
		margin-top: 40upx;
		margin-left: 10upx;
	}
	page,
		view {
			display: flex;
		}
		
		page {
			display: flex;
			min-height: 100%;
			background-color:#FFFFFF;
		}
		
		template {
			display: flex;
			flex: 1;
		}
	/* .appliciation{
		margin: 30upx;
		flex-direction:column;
		height:200upx;
		border-top-style: solid;
		border-top-width: 5upx;
		border-top-color:#F1F1F1;
		
	} */
/* 	.button-view {
		width: 750upx;
		margin-top: 750upx;
		padding: 0 20upx;
		box-sizing: border-box;
		flex-direction: column;
	}
	
	button {
		margin-bottom: 10upx;
		width: 710upx;
		height: 80upx;
		line-height: 80upx;
		text-align: center;
		font-size: 38upx;
		border-radius: 150upx;
		
	}
	
	button.publish {
		border-radius: 150upx;
	} */
</style>
